<template>
    <ul class="user_Overview flex">
        <li class="user_Overview-item" style="color: #00fdfa">
            <div class="user_Overview_nums allnum ">
				<!-- 仪器instruments 设施infrastructure-->
                <dv-digital-flop :config="instConfig" style="width:100%;height:100%;" />
            </div>
            <p>总仪器数</p>
        </li>
        <li class="user_Overview-item" style="color: #07f7a8">
            <div class="user_Overview_nums online">
                <dv-digital-flop :config="infrastConfig" style="width:100%;height:100%;" />
            </div>
            <p>总设施数</p>
        </li>
        <li class="user_Overview-item" style="color: #e3b337">
            <div class="user_Overview_nums offline">
                <dv-digital-flop :config="orderConfig" style="width:100%;height:100%;" />
            </div>
            <p>出租数量</p>
        </li>
        <li class="user_Overview-item" style="color: #f5023d">
            <div class="user_Overview_nums laramnum">
                <dv-digital-flop :config="idleConfig" style="width:100%;height:100%;" />
            </div>
            <p>空闲仪器</p>
        </li>
		
    </ul>
</template>

<script>
import { currentPOST } from 'api/modules'
let style = {
    fontSize: 24
}
export default {
    data() {
        return {
            options: {},
            timer: null,
            instConfig: {
                number: [1000],
                content: '{nt}',
                style: {
                    ...style,
                    fill: "#00fdfa",
                },
            },
            infrastConfig: {
                number: [0],
                content: '{nt}',
                style: {
                    ...style,
                    fill: "#07f7a8",
                },
            },
            orderConfig: {
                number: [0],
                content: '{nt}',
                style: {
                    ...style,
                    fill: "#e3b337",
                },
            },
            idleConfig: {
                number: [0],
                content: '{nt}',
                style: {
                    ...style,
                    fill: "#f5023d",
                },
            }

        };
    },
    filters: {
        numsFilter(msg) {
            return msg || 0;
        },
    },
    created() {
        this.getData()
    },
    beforeDestroy() {
        this.clearData()
    },
    methods: {
        clearData() {
            if (this.timer) {
                clearInterval(this.timer)
                this.timer = null
            }
        },
        getData() {
            currentPOST("/ipac-apic/bigScreen/deviceOverview").then((res) => {
				if(res.code == 200) {
					this.switper()
					this.instConfig = {
						...this.instConfig,
						number: [res.data.instrumentCount]
					}
					this.infrastConfig = {
						...this.infrastConfig,
						number: [res.data.infrastructureCount]
					}
					this.orderConfig = {
						...this.orderConfig,
						number: [res.data.deviceOrderCount]
					}
					this.idleConfig = {
						...this.idleConfig,
						number: [res.data.deviceIdleCount]
					}
				}
            });
        },
        //轮询
        switper() {
            if (this.timer) {
                return
            }
            let looper = (a) => {
                this.getData()
            };
            this.timer = setInterval(looper, this.$store.state.setting.echartsAutoTime);
        },
    },
};
</script>
<style lang='scss' scoped>
.user_Overview {
    li {
        flex: 1;
        p {
            text-align: center;
            font-size: 15px;
        }
        .user_Overview_nums {
            width: 100px;
            height: 100px;
            text-align: center;
            line-height: 100px;
            font-size: 22px;
            margin: 50px auto 20px;
            background-size: cover;
            background-position: center center;
            position: relative;

            &::before {
                content: '';
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                left: 0;
            }

            &.bgdonghua::before {
                animation: rotating 14s linear infinite;
            }
        }

        .allnum {
            /* background-image: url("../../assets/img/left_top_lan.png"); */
            &::before {
                background-image: url("../../assets/img/left_top_lan.png");
            }
        }

        .online {
            &::before {
                background-image: url("../../assets/img/left_top_lv.png");

            }
        }

        .offline {
            &::before {
                background-image: url("../../assets/img/left_top_huang.png");

            }
        }

        .laramnum {
            &::before {
                background-image: url("../../assets/img/left_top_hong.png");

            }
        }
    }
}
</style>